package com.huike.web.controller.contract;

import com.huike.common.annotation.Log;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.domain.entity.SysUser;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.enums.BusinessType;
import com.huike.contract.domain.vo.TransferVo;
import com.huike.contract.service.ITransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/transfer")
public class TransferController extends BaseController {

    @Autowired
    private ITransferService transferService;

    /**
     * 转派线索或商机
     */
    @PutMapping("assignment/{type}/{userId}/{transferUserId}")
    public AjaxResult assignment(@PathVariable String type,
                                 @PathVariable Long userId,
                                 @PathVariable Long transferUserId) {

        transferService.addTransfer(type,userId,transferUserId);
        return AjaxResult.success();
    }

    /**
     * 转派列表
     */
    @GetMapping("list")
    public TableDataInfo list(SysUser user) {
        List<TransferVo> list = transferService.selectTransferList(user);
        return getDataTablePage(list);
    }


}